# Libraries
library(tidyverse)
library(sf)
library(units)
library(USAboundaries)
library(rnaturalearth)
library(gghighlight)
library(ggrepel)
library(knitr)
library(plotly)Figure 1: Ten most populated cities in the US. An sf object was created from a dataframe containing all of the cities in the US. The ten most populated citiies were then extracted and plotted over an sf object of the continetal US sf object using ggplot.
Figure 2: US cities that are the furthest away from the international border. Distances were calculated by applying the st_distance() function on a Sf object containing all US cities and a unioned contentinal US sf object.
| City | State | Distance to border |
|---|---|---|
| Dresden | Kansas | 1012.317 |
| Herndon | Kansas | 1007.750 |
| Hill City | Kansas | 1005.147 |
| Atwood | Kansas | 1004.734 |
| Jennings | Kansas | 1003.646 |
Figure 3: US cities that are the furthest away from a state border. Distances were calculated by applying the st_distance() function on a Sf object containing all US cities and the contentinal US sf object.
Figure 4: Highlighted US Cities which are equidistance between the Mexican and Candian borders. The cities which are equal distance between the Mexican and Canadian borders were calculated by taking the absolute difference between cities distances between the respective borders. Equidistant cities are highlighted by using the gghighlight function and the labeled cities are the five most populated cities in this region.
| City | State | Distance to Mexico border |
|---|---|---|
| Caribou | Maine | 3250.334 |
| Presque Isle | Maine | 3234.570 |
| Calais | Maine | 3134.348 |
| Eastport | Maine | 3125.624 |
| Old Town | Maine | 3048.366 |
| City | State | Distance to Canada border |
|---|---|---|
| Guadalupe Guerra | Texas | 2206.455 |
| Sandoval | Texas | 2205.641 |
| Fronton | Texas | 2204.784 |
| Fronton Ranchettes | Texas | 2202.118 |
| Evergreen | Texas | 2202.020 |
Figure 5: US cities which are within 160km of the international border. There are 12,283 cities found in this region with a total population of ~260 million people which equates to ~65% of the total US population. The labeled cities represent the most populated city in each state within the border zone.
| Border zone population | Percent of total US population | Number of cities |
|---|---|---|
| 259935815 | 65.43979 | 12283 |